﻿using System;
using Gumini.JulaDB.Enums;

namespace Gumini.JulaDB
{
    public class LogMessage
    {
        internal LogMessage(string message)
        {
            this.Time = DateTime.Now;
            this.Message = message;
            this.Type = MessageType.Information;
            this.ErrorCode = ErrorCode.Success;
            this.Position = null;
        }

        internal LogMessage(string message, ErrorCode errorCode, SourcePosition position)
        {
            this.Time = DateTime.Now;
            this.Message = message;
            this.Type = MessageType.Error;
            this.ErrorCode = errorCode;
            this.Position = position;
        }

        public DateTime Time { get; private set; }

        public ErrorCode ErrorCode { get; private set; }

        public MessageType Type { get; private set; }

        public string Message { get; private set; }

        public SourcePosition Position { get; private set; }

        public override string ToString()
        {
            return this.Message;
        }
    }
}
